Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add khidusage_keyboardclear as possible option for text field clear on iOS #810

Closed
wants to merge 1 commit into from

Conversation

mykola-mokhnach
Copy link

if (![FBKeyboard typeText:textToType error:error]) {
NSString *backspacesToType = [backspaceDeleteSequence fb_repeatTimes:preClearTextLength];
#if TARGET_OS_IOS
if (retry == MAX_CLEAR_RETRIES - 2) {
Copy link
Member

@KazuCocoa KazuCocoa Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so,

1st attempt -> typeText
2nd -> fb_performIOHIDEventWithPage
3rd -> tapWithNumberOfTaps:3

correct? Or I wondered if we could try the fb_performIOHIDEventWithPage first, then typeText, but the last one will be tapWithNumberOfTaps:3

Copy link
Member

@KazuCocoa KazuCocoa Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's about #811 ?

Comment on lines +164 to +168
if (retry >= MAX_CLEAR_RETRIES - 1) {
return [[[FBErrorBuilder builder]
withDescriptionFormat:@"'%@' cannot be cleared of its text", snapshot.fb_description]
buildError:error];
} else if (![FBKeyboard typeText:backspacesToType error:error]) {
Copy link
Member

@KazuCocoa KazuCocoa Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change here to:

    if (retry >= MAX_CLEAR_RETRIES - 1) {
      return [FBKeyboard typeText:backspaceDeleteSequence error:error];
    } else if (![FBKeyboard typeText:backspacesToType error:error]) {
      return NO;
    }

?
In the current implementation, calling clear text for an empty search field generates the below error. (This was Apple's general search field in the tvOS's content search)

> e.clear
Selenium::WebDriver::Error::InvalidElementStateError: Error Domain=com.facebook.WebDriverAgent Code=1 "'XCUIElementTypeSearchField' cannot be cleared of its text" UserInfo={NSLocalizedDescription='XCUIElementTypeSearchField' cannot be cleared of its text}

This was because self.fb_takeSnapshot.value kept returning its place holder while the field was empty (self.fb_takeSnapshot.label was nil). So we potentially can add label comparison as well in addition to currentValue = self.fb_takeSnapshot.value... but not sure it is a better idea.

So, just keeping existing behavior with return [FBKeyboard typeText:backspaceDeleteSequence error:error]; would be safe to keep current clear text's behavior for already cleared field.

@mykola-mokhnach
Copy link
Author

closed in favour of #810

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants